<html>
<head><meta charset="utf-8"><title>Implementing `confusable_idents` · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html">Implementing `confusable_idents`</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="184802753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184802753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184802753">(Jan 04 2020 at 12:49)</a>:</h4>
<p>So i'll start looking into how to implement <code>confusable_idents</code> and <code>mixed_script_confusables</code>, whichever is easier to implement.</p>



<a name="184802815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184802815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184802815">(Jan 04 2020 at 12:51)</a>:</h4>
<p>One immediate question i come up with, is that these two lints are kind of "accumulative", where each identifiers it meets is compared with everything it has seen before.</p>



<a name="184802880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184802880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184802880">(Jan 04 2020 at 12:52)</a>:</h4>
<p>Since there's ongoing "parallel rustc" efforts going on, this makes me wonder how would i store the previous states.</p>



<a name="184802945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184802945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184802945">(Jan 04 2020 at 12:55)</a>:</h4>
<p>I think i needs some instructions here again...  <span class="user-mention" data-user-id="126931">@centril</span> <span class="user-mention" data-user-id="132040">@Manish Goregaokar</span> <span class="user-mention" data-user-id="116466">@Zoxc</span> <br>
<a href="https://github.com/rust-lang/rust/issues/55467" target="_blank" title="https://github.com/rust-lang/rust/issues/55467">https://github.com/rust-lang/rust/issues/55467</a></p>



<a name="184802953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184802953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manish Goregaokar <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184802953">(Jan 04 2020 at 12:55)</a>:</h4>
<p>Yeah no I wouldn't touch those yet</p>



<a name="184802997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184802997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manish Goregaokar <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184802997">(Jan 04 2020 at 12:56)</a>:</h4>
<p><span class="user-mention" data-user-id="119031">@Esteban Küber</span> said he had a wip branch for some of this</p>



<a name="184803001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184803001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manish Goregaokar <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184803001">(Jan 04 2020 at 12:56)</a>:</h4>
<p>Mixed script confusables is one you might want to try, the rfc suggests a way to make it super efficient</p>



<a name="184803006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184803006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Manish Goregaokar <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184803006">(Jan 04 2020 at 12:56)</a>:</h4>
<p>I'd just leave the confusables lint for now</p>



<a name="184803073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184803073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184803073">(Jan 04 2020 at 12:58)</a>:</h4>
<p>Ok. I think i'll just find something else to play with for now. <span aria-label="slight smile" class="emoji emoji-1f642" role="img" title="slight smile">:slight_smile:</span></p>



<a name="184803088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184803088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184803088">(Jan 04 2020 at 12:59)</a>:</h4>
<p>I have also read some code about "Adjustments to "bad style" lints" item</p>



<a name="184803096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184803096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184803096">(Jan 04 2020 at 12:59)</a>:</h4>
<p>i think there's nothing that needs to be changed, if i've read it correctly.</p>



<a name="184803158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184803158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184803158">(Jan 04 2020 at 13:01)</a>:</h4>
<p>Maybe we need to review the progress and tick some checkboxes in the tracking issue at some point.</p>



<a name="184803174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184803174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184803174">(Jan 04 2020 at 13:01)</a>:</h4>
<blockquote>
<p>A fast way to implement this is to compute skeleton for each identifier once and place the result in a hashmap as a key. If one tries to insert a key that already exists check if the two identifiers differ from each other. If so report the two confusable identifiers.</p>
</blockquote>



<a name="184803226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184803226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184803226">(Jan 04 2020 at 13:03)</a>:</h4>
<p>So it's based on a hashmap, and it still has parallelism issues. Maybe i'll wait for <span class="user-mention" data-user-id="119031">@Esteban Küber</span> at this point.</p>



<a name="184807436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184807436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184807436">(Jan 04 2020 at 15:03)</a>:</h4>
<p>I don't think the parser is in the critical path for compilation speed in any existing non heavily nested project, I have a few with generated code that go in the hundreds of thousands of lines and the problem there is after the ast is created</p>



<a name="184807484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184807484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184807484">(Jan 04 2020 at 15:04)</a>:</h4>
<p>Can't this just walk the entire crate at a later point and look at all  identifiers instead of carrying state around?</p>



<a name="184807485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184807485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184807485">(Jan 04 2020 at 15:04)</a>:</h4>
<p>And for heavy meeting the problem is blowing the stack on heavy recurtion</p>



<a name="184807497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184807497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184807497">(Jan 04 2020 at 15:05)</a>:</h4>
<p>We can but we'd also want to use this for ident not found suggestions</p>



<a name="184807621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184807621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184807621">(Jan 04 2020 at 15:08)</a>:</h4>
<p>We do have some big rwlocks already, right?</p>



<a name="184807630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184807630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184807630">(Jan 04 2020 at 15:09)</a>:</h4>
<p>That might not go away anytime soon</p>



<a name="184807704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184807704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184807704">(Jan 04 2020 at 15:10)</a>:</h4>
<p>When do <code>ident not found suggestions</code> happen? I assume we can collect all idents after macro expansion.</p>



<a name="184807716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184807716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Zoxc <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184807716">(Jan 04 2020 at 15:11)</a>:</h4>
<p>You can't really use locks for this kind of state since it would be non-deterministic and also not tracked by incremental compilation.</p>



<a name="184815680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184815680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184815680">(Jan 04 2020 at 19:08)</a>:</h4>
<blockquote>
<p>When do <code>ident not found suggestions</code> happen? I assume we can collect all idents after macro expansion.</p>
</blockquote>
<p>Then you will miss the identifiers of expanded macros.</p>



<a name="184854551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Implementing%20%60confusable_idents%60/near/184854551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Implementing.20.60confusable_idents.60.html#184854551">(Jan 05 2020 at 16:19)</a>:</h4>
<p>Feel free to ping me if there's any actionable item on my side. I'm happy to help push this implementation work forward.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>